package cz.khfotbal.beans;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cz.khfotbal.domain.Referee;
import cz.khfotbal.service.RefereeService;

@Component
@Scope(value = "session")
public class RefereeBean {

	@Autowired
	private RefereeService refereeService;

	private Referee newReferee = new Referee();
	private Referee selectedReferee;
	private List<Referee> filteredReferees;

	public List<Referee> getRefereeList() {
		return refereeService.getAllReferees();
	}

	public void updateReferee() {
		if (selectedReferee != null) {
			refereeService.updateReferee(selectedReferee);
		}
	}

	public void createReferee() {
		refereeService.createReferee(newReferee);
		newReferee = new Referee();
	}

	public RefereeService getRefereeService() {
		return refereeService;
	}

	public void setRefereeService(RefereeService refereeService) {
		this.refereeService = refereeService;
	}

	public Referee getNewReferee() {
		return newReferee;
	}

	public void setNewReferee(Referee newReferee) {
		this.newReferee = newReferee;
	}

	public Referee getSelectedReferee() {
		return selectedReferee;
	}

	public void setSelectedReferee(Referee selectedReferee) {
		this.selectedReferee = selectedReferee;
	}

	public List<Referee> getFilteredReferees() {
		return filteredReferees;
	}

	public void setFilteredReferees(List<Referee> filteredReferees) {
		this.filteredReferees = filteredReferees;
	}
}
